package week2oo;

public class Animal {

	private String name;
	private int hp;
	private int aggressivity;
	private int defense;
	
	public Animal(String name, int hp, int aggressivity, int defense) {
		this.name = name;
		this.hp = hp;
		this.aggressivity = aggressivity;
		this.defense = defense;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getHp() {
		return hp;
	}

	public void setHp(int hp) {
		this.hp = hp;
	}

	public int getAggressivity() {
		return aggressivity;
	}

	public void setAggressivity(int aggressivity) {
		this.aggressivity = aggressivity;
	}

	public int getDefense() {
		return defense;
	}

	public void setDefense(int defense) {
		this.defense = defense;
	}

	public void attack(Animal dst) {
		int damage = this.aggressivity - dst.getDefense();
		if (dst.getHp() - damage > 0) {
			dst.setHp(dst.getHp() - damage);
		} else {
			dst.setHp(0);
		}
	}
}
